﻿using System;

namespace DotNetImage.Imaging.Filters
{
    /// <summary>
    /// R = G = B = 0.333RED + 0.333GREEN + 0.333BLUE
    /// </summary>
    public class GrayFilter : FilterBase
    {
        private double redFactor;
        private double greenFactor;
        private double blueFactor;

        public GrayFilter(double RedFactor, double GreenFactor, double BlueFactor)
        {
            redFactor = RedFactor;
            greenFactor = GreenFactor;
            blueFactor = BlueFactor;
        }

        protected override void ProcessPixel(ref Pixel pix, uint x, uint y)
        {
            uint value = (uint)(pix.Red * redFactor + pix.Green * greenFactor + pix.Blue * blueFactor);
            pix.SetRGB(value, value, value);
        }
    }
}
